using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneMgr
{
    public ISceneState m_State;
    public bool m_Running = false;
    public SceneMgr()
    {

    }

    public void SetScene(ISceneState scene, string name)
    {
        if (m_State != null)
        {
            m_State.StateEnd();
        }
        m_Running = false;
        LoadScene(name);
        m_State = scene;
    }

    private void LoadScene(string name)
    {
        if (name == null || name.Length == 0)
        {
            return;
        }
        SceneManager.LoadScene(name);
    }

    public void StateUpdate()
    {
        if (m_State != null && !m_Running)
        {
            m_Running = true;
            m_State.StateBegin();
        }
        if (m_State != null)
        {
            m_State.UpDateScene();
        }
    }
}